/**
 * 
 */
package systole.persistence.brokersDB;

import java.util.List;
import org.hibernate.HibernateException;

import org.hibernate.Session;
import systole.domain.analysis.results.AnalysisResult;
import systole.domain.persons.Patient;
import systole.exceptions.ExceptionDAO;
import systole.persistence.FacadeDB;
import systole.persistence.brokersInterface.AnalysisResultBroker;
import systole.view.messages.ErrorMessages;

/**
 * @author jmj
 *
 */
public class AnalysisResultBrokerDB extends BrokerDB implements
		AnalysisResultBroker {

	/**
	 * 
         */
	public AnalysisResultBrokerDB() {
		super();
	}

	/* (non-Javadoc)
	 * @see systole.persistence.brokersInterface.AnalysisResultBroker#getAnalisysResultById(long)
	 */
	@Override
	public AnalysisResult getAnalisysResultById(Integer id)throws ExceptionDAO {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see systole.persistence.brokersInterface.AnalysisResultBroker#getPatientAnalisysResults(systole.domain.persons.Patient)
	 */
	@Override
	public List<AnalysisResult> getPatientAnalisysResults(Patient patient) throws ExceptionDAO{
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see systole.persistence.brokersInterface.AnalysisResultBroker#insert(systole.domain.analysis.AnalysisResult)
	 */
	@Override
	public void insert(AnalysisResult analysisResult)throws ExceptionDAO {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see systole.persistence.brokersInterface.AnalysisResultBroker#update(systole.domain.analysis.AnalysisResult)
	 */
	@Override
	public void update(AnalysisResult analysisResult)throws ExceptionDAO {
	 try {
            this.logger.logDebug("Updating Analysis");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            currentSession.update(analysisResult);
            this.logger.logDebug("Analysis updated");
        } catch (HibernateException e) {
            this.logger.logError("error on update analysis, msg: " + e.getMessage());
            throw new ExceptionDAO(ErrorMessages.CHANGES_NOT_SAVE, e.fillInStackTrace());
        }
    	}

}
